package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.*;
import com.egao.common.core.annotation.OperLog;
import com.egao.orderB.entity.ExStorage;
import com.egao.orderB.service.ExStorageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.ui.Model;


/**
 *
 * 出库信息
 * @author : Doman
 * @date : 2022-01-07 17:09:31
 * @version ：1.0
 */

@Api(tags = "出库信息")
@RestController
@RequestMapping("/api/orderB/exStorage")
public class ExStorageController extends BaseController {

	@Autowired
	private ExStorageService exStorageService;

	/**
	 * 分页查询列表
	 */
	@PreAuthorize("hasAuthority('orderB:exStorage:list')")
  @ApiOperation(value ="分页查询出库信息",notes = "" +
    "limit:每页显示几行 必填\n" +
    "page:第几页 必填\n" +
    "billOfLading:提单号\n" +
          "vessel:船名\n" +
          "voyage:航次\n" +
    "date1: warehousing_date开始时间\n" +
    "date2: warehousing_date结束时间\n" +
    " \n\n\n" +
    "返回的结果:\n" +
    "id:id\n" +
    "putStorageIds: 入库ids 哪些入库单 1,2,3\n" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
    "boxType:箱型\n" +
    "billOfLading:提单号\n" +
    "portOfDeparture:起运港\n" +
    "portOfDestination:目的港\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "orderNum:排序\n" +
    "createTime:创建时间\n" +
    "createUser:创建人\n" +
    "updateTime:更新时间\n" +
    "updateUser:更新人\n" +
    "",httpMethod = "POST")
  @ApiPageParam
  @PostMapping("/list")
  public JsonResult page(PageResult2<T> page, ExStorage exStorage) throws Exception{
    return exStorageService.list(page, exStorage, getLoginUser());
  }

  /**
   * 查询全部出库信息
   */
  @PreAuthorize("hasAuthority('orderB:exStorage:list')")
  @ApiOperation("查询全部出库信息")
  @PostMapping("/listAll")
  public JsonResult list(ExStorage exStorage){
    return exStorageService.list(exStorage, getLoginUser());
  }

  /**
   * 查询全部出库信息
   */
  @PreAuthorize("hasAuthority('orderB:exStorage:list')")
  @ApiOperation(value ="首页出库量",notes = "" +
          "返回: \nproductName:类型\n" +
          "num:数量\n" +
          "")
  @PostMapping("/listVolume")
  public JsonResult listVolume(ExStorage exStorage){
    return exStorageService.listVolume(exStorage, getLoginUser());
  }

  /**
   * 查询全部出库信息
   */
  @PreAuthorize("hasAuthority('orderB:exStorage:list')")
  @ApiOperation(value ="首页按月出库订单数",notes = "" +
          "date1:开始月份20222022-01\n" +
          "date2:结束月份2022-03\n" +
          "keywords:具体到某一个月 2022-03  \n" +
          "")
  @PostMapping("/listMonth")
  public JsonResult listMonth(ExStorage exStorage){
    return exStorageService.listMonth(exStorage, getLoginUser());
  }

  /**
   * 根据id查询出库信息
   */
  @PreAuthorize("hasAuthority('orderB:exStorage:list')")
  @ApiOperation("根据id查询出库信息")
  @PostMapping("/get")
  public JsonResult get(ExStorage exStorage) {
    return exStorageService.getById(exStorage);
  }


  /**
   * 添加入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:save')")
  @OperLog(value = "出库信息,出库商品详情 一起保存 ", desc = "添加", param = false, result = true)
  @ApiOperation(value ="出库信息,出库商品详情 一起保存 ",notes = "" +
    "exStorage:{\n" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
          "boxType:箱型\n" +
          "billOfLading:提单号\n" +
          "portOfDeparture:起运港\n" +
          "portOfDestination:目的港\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "orderNum:排序\n" +
    "}\n\n\n" +
    "stockList:[{\n" +
    "id:id\n" +
    "sku:SKU\n" +
    "name:货名\n" +
    "remark:备注\n" +
    "num:件数\n" +
    "pack:包装\n" +
    "weight:重量\n" +
    "length:长\n" +
    "width:宽\n" +
    "high:高\n" +
    "volume:体积\n" +
    "palletNum:托盘数\n" +
    "orderNum:排序\n" +
    "}]\n\n\n" +
    "}\n\n\n" +
    "",httpMethod = "POST")
  @PostMapping("/saveStorage")
  public JsonResult saveExStorage(Model model, String exStorage, String stockList) {
    return exStorageService.saveExStorage(exStorage, stockList, getLoginUser());
  }


  /**
   * 添加入库信息
   */
  @PreAuthorize("hasAuthority('orderB:putStorage:save')")
  @OperLog(value = "出库信息,出库商品详情 一起保存 ", desc = "添加", param = false, result = true)
  @ApiOperation(value ="出库信息,出库商品详情 一起保存 ",notes = "" +
          "putStorageIds: 入库id   1,2,3\n" +
          "boxType:箱型\n" +
          "billOfLading:提单号\n" +
          "portOfDeparture:起运港\n" +
          "portOfDestination:目的港\n" +
          "vessel: 船名\n" +
          "voyage: 航次\n" +
          "",httpMethod = "POST")
  @PostMapping("/saveExStorageByPutGoods")
  public JsonResult saveExStorageByPutGoods(Model model, String putStorageIds,ExStorage exStorage)  {
    try {
      return exStorageService.saveExStorageByPutGoods(putStorageIds, exStorage, getLoginUser());
    } catch (Exception e) {
      return JsonResult.error(e.getMessage());
    }
  }

  /**
   * 添加出库信息
   */
  @PreAuthorize("hasAuthority('orderB:exStorage:save')")
  @OperLog(value = "出库信息", desc = "添加", param = false, result = true)
  @ApiOperation(value ="添加出库信息",notes = "" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
          "boxType:箱型\n" +
          "billOfLading:提单号\n" +
          "portOfDeparture:起运港\n" +
          "portOfDestination:目的港\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "orderNum:排序\n" +
    "",httpMethod = "POST")
  @PostMapping("/save")
  public JsonResult save(Model model, ExStorage exStorage) {
    return exStorageService.save(exStorage, getLoginUser());
  }

  /**
   * 修改出库信息
   */
  @PreAuthorize("hasAuthority('orderB:exStorage:update')")
  @OperLog(value = "出库信息", desc = "修改", param = false, result = true)
  @ApiOperation(value ="修改出库信息",notes = "" +
    "id:id\n" +
    "specifyJobNumber:指定工作号\n" +
    "poCode:PO/原单号\n" +
    "referenceId:reference_id\n" +
    "soCode:SO/入仓号\n" +
    "customerCode:客户入仓号\n" +
    "transferOrderNo:转单号\n" +
    "startDate:接单/起运日期\n" +
    "warehousingDate:货好/入仓日期\n" +
    "arrivalDate:到达日期\n" +
    "vessel:船名\n" +
    "voyage:航次\n" +
          "boxType:箱型\n" +
          "billOfLading:提单号\n" +
          "portOfDeparture:起运港\n" +
          "portOfDestination:目的港\n" +
    "carrier:承运人\n" +
    "productName:产品名称\n" +
    "productType:货物类型\n" +
    "packNum:包装件数\n" +
    "trackEdi:跟踪EDI\n" +
    "deliveryState:派送状态\n" +
    "totalGrossWeight:总毛重(KGS)\n" +
    "volumeM3:体积(M3)\n" +
    "costWeight:计费重\n" +
    "weightConversionFactor:重量换算系数\n" +
    "billingTon:计费吨\n" +
    "bubbleSeparation:分泡(%)\n" +
    "num:件数\n" +
    "weight:重量\n" +
    "volume:体积\n" +
    "warehouseName:库房名称\n" +
    "billingMethod:计费方式\n" +
    "orderNum:排序\n" +
    "",httpMethod = "POST")
  @PostMapping("/update")
  public JsonResult update(Model model, ExStorage exStorage) {
    return exStorageService.update(exStorage, getLoginUser());
  }

  /**
   * 删除出库信息
   */
  @PreAuthorize("hasAuthority('orderB:exStorage:remove')")
  @OperLog(value = "出库信息", desc = "删除", result = true)
  @ApiOperation(value ="删除出库信息",notes = "" +
    "id:id\n" +
    "",httpMethod = "POST")
  @PostMapping("/remove")
  public JsonResult remove(ExStorage exStorage ) {
    return exStorageService.remove(exStorage, getLoginUser());
  }

}
